import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:sk_base/widget/base_widget.dart';
import 'package:sk_base_example/app.dart';
import 'package:sk_base_example/router/test_router.dart';

/**
 *
 * @ProjectName:    sk_base
 * @Package:        example.lib.page
 * @ClassName:      my_page
 * @Description:    dart文件作用
 * @Author:         孙浩
 * @CreateDate:     5/22/21 4:07 PM
 */
class MyPage extends StatefulWidget {
  final Map keyMap;

  MyPage({this.keyMap});

  @override
  State<StatefulWidget> createState() => _State();
}

class _State extends SKBaseState<MyPage> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget buildView(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(pageTitle),
      ),
      body: Column(
        children: [
          Text("${widget.keyMap}"),
          FlatButton(
              onPressed: () {
                AppStaticData.fluroRouter.navigateTo(
                    context, TestRouter.Test2Page,
                    routeSettings: RouteSettings(arguments: {
                      "key": "word",
                      "value": widget.keyMap["value"] + 1
                    }));
              },
              child: Text("push self")),
          FlatButton(
              onPressed: () {
                AppStaticData.routerManager.lockRouter();
                AppStaticData.fluroRouter.navigateTo(
                    context, TestRouter.Test2Page,
                    routeSettings: RouteSettings(arguments: {
                      "key": "word",
                      "value": widget.keyMap["value"] + 1
                    }));
              },
              child: Text("lock name and push self")),
          FlatButton(
              onPressed: () {
                Navigator.popUntil(context, (route) => route ==  AppStaticData.routerManager.routerLock);
                // AppStaticData.fluroRouter..(
                //     context, AppStaticData.routerManager.routerLockName,
                //     clearStack: true);
                AppStaticData.routerManager.unLockRouter();
              },
              child: Text("back2LastPage")),
        ],
      ),
    );
  }

  @override
  String setPageTitle() => "个人中心";
}
